﻿<UserControl x:Class="OneTo50.UserControls.ScoreListControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:uc="clr-namespace:OneTo50.UserControls"
             xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
             mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    d:DesignHeight="480" d:DesignWidth="480" Loaded="UserControl_Loaded">

    <Grid>
        <Grid x:Name="gdScoreList">
            <Grid.RowDefinitions>
                <RowDefinition Height="50" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="50" />
                    <ColumnDefinition Width="150" />
                    <ColumnDefinition Width="130" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <TextBlock Text="No" Style="{StaticResource ListHeaderText}" />
                <TextBlock Grid.Column="1" Text="name" Style="{StaticResource ListHeaderText}" />
                <TextBlock Grid.Column="2" Text="score" Style="{StaticResource ListHeaderText}" />
                <TextBlock Grid.Column="3" Text="level" Style="{StaticResource ListHeaderText}" />
            </Grid>
            <ListBox Grid.Row="1" x:Name="lbWorldScores">
                <ListBox.ItemContainerStyle>
                    <Style TargetType="ListBoxItem">
                        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                    </Style>
                </ListBox.ItemContainerStyle>
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="50" />
                                <ColumnDefinition Width="150" />
                                <ColumnDefinition Width="130" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <TextBlock Grid.Column="0" Text="{Binding SortOrder}" Style="{StaticResource ListItemText}" />
                            <TextBlock Grid.Column="1" Text="{Binding UserName}" Style="{StaticResource ListItemText}" />
                            <TextBlock Grid.Column="2" Foreground="White" Text="{Binding Score, Converter={StaticResource ScoreFormatConverter}}" Style="{StaticResource ListItemText}" />
                            <uc:StarsRating HorizontalAlignment="Center" Grid.Column="3" Stars="{Binding Score, Converter={StaticResource StarLevelConverter}}" />
                            <Border Grid.Row="1" Grid.ColumnSpan="4" BorderThickness="0,0,0,1">
                                <StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
                                    <Image Source="{Binding CountryCode, Converter={StaticResource FlagImageSourceConverter}}" VerticalAlignment="Center" />
                                    <TextBlock Text="{Binding CountryCode, Converter={StaticResource CountryTipInfoConverter}}" Style="{StaticResource ListItemText}" Margin="5,0,30,0" Foreground="White" FontSize="20" VerticalAlignment="Center" />
                                    <TextBlock Text="{Binding CreatedTime, Converter={StaticResource DateConverter}}" Style="{StaticResource ListItemText}" />
                                </StackPanel>
                                <Border.BorderBrush>
                                    <LinearGradientBrush>
                                        <GradientStop Color="#00007900" Offset="0"></GradientStop>
                                        <GradientStop Color="#007900" Offset="0.35"></GradientStop>
                                        <GradientStop Color="White" Offset="0.5"></GradientStop>
                                        <GradientStop Color="#007900" Offset="0.55"></GradientStop>
                                        <GradientStop Color="#00007900" Offset="1"></GradientStop>
                                    </LinearGradientBrush>
                                </Border.BorderBrush>
                            </Border>
                        </Grid>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </Grid>
        <Grid x:Name="gdError" Margin="10" VerticalAlignment="Top" Visibility="Collapsed">
            <TextBlock Style="{StaticResource ListHeaderText}" Foreground="#C3C3C3" Text="Sorry, can not get the scores for now. Please make sure you have connected to the internet and try again." TextWrapping="Wrap" FontSize="30" ></TextBlock>
        </Grid>
        <toolkit:PerformanceProgressBar VerticalAlignment="Bottom" IsIndeterminate="True" Visibility="Collapsed" x:Name="ppb"  />
    </Grid>
</UserControl>
